//
//  UIBarButttonItem.swift
//  SinaWeibo
//
//  Created by gaoliang on 15/11/20.
//  Copyright © 2015年 gaoliang. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    //自定义 barbuttonitem的遍历函数
    // 通过图片
    convenience init(imageName: String,target: AnyObject?, actionName: String?){
        let btn = UIButton(type: .Custom)
        btn.setImage(UIImage(named: imageName) , forState: .Normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState:UIControlState.Selected)
        if let action = actionName, targetObj = target {
            btn.addTarget(targetObj, action: Selector(action), forControlEvents: UIControlEvents.TouchUpInside)
        }
        btn.sizeToFit()
        
        self.init(customView:btn)
    }
}

